cmake_minimum_required(VERSION 3.4.1)

include_directories(../lua)
include_directories(..)
include_directories(../../external/openssl/include)

add_definitions(-DLUA_USE_DLOPEN -DLUA_USE_C89 -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2)

set(SRC_LIST
        x509.c
        context.c
        ssl.c
        config.c
        ec.c
        )

add_library(luasec SHARED ${SRC_LIST})

add_library(crypto_static STATIC IMPORTED)
set_target_properties(crypto_static
        PROPERTIES IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/external/openssl/prebuilt/${CMAKE_ANDROID_ARCH_ABI}/libcrypto.a)

add_library(ssl_static STATIC IMPORTED)
set_target_properties(ssl_static
        PROPERTIES IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/external/openssl/prebuilt/${CMAKE_ANDROID_ARCH_ABI}/libssl.a)

target_link_libraries(luasec lua luasocket ssl_static crypto_static)